--#include "data\config\vip\SuperVipConfig.lua" once



function BuySuperVip(sysarg)
	if Actor.getIntProperty(sysarg, PROP_ACTOR_SUPER_VIP) > 0 then
		return
	end

	local createDay = Actor.getDaysSinceCreateRole(sysarg)
	local totalRecharge = Actor.getIntProperty(sysarg, PROP_ACTOR_DRAW_YB_COUNT)
	if createDay <= SuperVipConfig.actNeedCreateRoleDay then
		if totalRecharge < SuperVipConfig.actNeedReChargeYuanBao then
			Actor.sendTipmsg(sysarg, string.format(Lang.ScriptTips.SuperVip001,SuperVipConfig.actNeedReChargeYuanBao),  ttFlyTip)
			return
		end
	else
		local consumes = {{type = qatYuanbao, id = 0, count = SuperVipConfig.actNeedConsumesYuanBao}}
		if not CheckConsumeCond(sysarg, consumes) then
	        return
	    end
		if not DoConsumeCond( sysarg, consumes, 1, LogIds.BuySuperVip, Lang.LogTips.BuySuperVip) then
			return
		end
	end

	Actor.setIntProperty(sysarg, PROP_ACTOR_SUPER_VIP, 1)
	Actor.collectOperate(sysarg,0) -- 重新计算角色属性

	local noticeStr = string.format(Lang.ScriptTips.SuperVip002, Actor.getName(sysarg))
    System.broadcastTipmsg(noticeStr, ttScreenCenter + ttChatWindow)
end

function OnSuperVipWithDrawYuanBao(sysarg,nYuanBao)
	local storePoint = math.floor(nYuanBao/SuperVipConfig.rechargeGetStorePointRate)
	local oldStorePoint = Actor.getIntProperty(sysarg, PROP_ACTOR_STOREPOINT)
	Actor.setIntProperty(sysarg, PROP_ACTOR_STOREPOINT, oldStorePoint + storePoint)
end